#include "../begonia.h"
#include "boss_3_2_seiko.h"
#include "boss_3_2_seino.h"
#include "../bullet/needlebullet.h"
#include "../base/scene.h"

boss_3_2_seiko::boss_3_2_seiko():boss(192.0,250.0,20.0,0.0,0.0,&f.head)
    {
        new boss_3_2_seino();
    }
boss_3_2_seiko::boss_3_2_seiko(double tx,double ty,double tr,double tvx,double tvy,bullet *h):boss(tx,ty,tr,tvx,tvy,h)
    {
    }
void boss_3_2_seiko::clone(bullet *h)
    {
        new boss_3_2_seiko(x,y,r,vx,vy,h);
    }
bool boss_3_2_seiko::move()
    {
        double t0=double(rand()%1000)/500.0*M_PI;
        if((int)t/3>(int)tlast/3)
        {
            needlebullet *t=new needlebullet(x+cos(t0)*10,y+sin(t0)*10,10,cos(t0)*2.0,sin(t0)*2.0,2.0,&f.head);
            t->c_b=1.0;
        }
        double wind,tmin=1e9;
        for(bullet *a=f.head.next;a!=&f.head;a=a->next)
            if(a->c_b==1.0&&(a->vy>1e-9&&f.py-a->y>1e-9)||(a->vy<-1e-9&&f.py-a->y<-1e-9))
            {
                double tt=(f.py-a->y)/a->vy,twind=2.0*(f.px-a->x-a->vx*tt)/sqr(tt);
                if(tt<tmin&&twind<0.03&&twind>-0.03) {wind=twind;tmin=tt;}
            }
        if(tmin<1e9)
        {
            for(bullet *a=f.head.next;a!=&f.head;a=a->next) if(a->c_b==1.0) {a->vx+=wind;((needlebullet*)a)->direction0();}
        }
        return true;
    }
